﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LangMauViet.Classes.Helper;
using LangMauViet.Models.Entity;

namespace LangMauViet.Models.Service
{
    public class CategoryService
    {
        public List<Category> GetCategory(long? parentId, int type)
        {
            try
            {
                JsonHelper<Category> jsonCategory = new JsonHelper<Category>();
                Hashtable hashTable = new Hashtable();
                hashTable.Add("type", type);
                hashTable.Add("parentId", parentId);
                hashTable.Add("versionId", 1);
                string result = jsonCategory.GetJsonResponse("getCategory", hashTable);
                List<Category> listCate = jsonCategory.ParseJsonResponse(result, "getCategoryResponse");
                return listCate;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public List<HotItem> GetHotItem(int type)
        {
            JsonHelper<HotItem> jsonHotItem = new JsonHelper<HotItem>();
            Hashtable hashtable = new Hashtable();
            hashtable.Add("type",type);
            hashtable.Add("orderBy",0);
            hashtable.Add("size",5);
            string result = jsonHotItem.GetJsonResponse("getHotItem", hashtable);
            List<HotItem> listHotItem = jsonHotItem.ParseJsonResponse(result, "getHotItemResponse");
            return listHotItem;
        }
                
    }
}